import {AppNavigationProp, ROUTES} from "@/app/route/RouteParams";
import {useNavigation} from "expo-router";
import {FlatList, Pressable} from "react-native";
import {ThemedView} from "@/components/ThemedView";
import {Button,Text} from "react-native-ui-lib";
import * as React from "react";
function handleItemPress(item: any) {

}
export function HomeMenuList() {
    const getButtonLabel = (item:number) => {
        switch (item) {
            case 0:
                return "跳到详情页";
            case 1:
                return "跳到表格页";
            case 2:
                return "跳到新闻页";
            case 3:
                return "跳到设置页";
            case 4:
                return "跳到帮助页";
            default:
                return "跳到默认页";
        }
    };
    const handleNavigation = (item) => {
        switch (item) {
            case 0:
                navigation.navigate(ROUTES.Detail, { id: 1 });
                break;
            case 1:
                navigation.navigate(ROUTES.Tableview);
                break;
            case 2:
                navigation.navigate(ROUTES.News);
                break;
            case 3:
                // navigation.navigate(ROUTES.Stats, { id: 3 });
                break;
            case 4:
                // navigation.navigate(ROUTES.Settings, { id: 4 });
                break;
            default:
                console.warn('Unknown route');
        }
    };
    const navigation: AppNavigationProp<typeof ROUTES.Detail> = useNavigation();
    return (
        <FlatList data={
            Array.from({length: 5}).map((_, i) => i)
        } renderItem={
            ({item}) =>
                <Pressable
                    key={item}
                    onPress={() => handleItemPress(item)}
                    android_ripple={{color: '#ccc'}}
                >
                    <ThemedView style={{padding: 10, flexDirection: 'row'}}>
                        <Button label={getButtonLabel(item)} onPress={() => handleNavigation(item)}>
                        </Button>
                    </ThemedView>
                </Pressable>
        }></FlatList>
    );
}
